Skip to main content

PolymorphicValidator<T, TProperty>

Performs runtime checking of the value being validated, and passes validation off to a subclass validator.

Assembly: ServiceStack.dll​
View Source​
Declaration
public class PolymorphicValidator<T, TProperty> : ChildValidatorAdaptor<T, TProperty>, IPropertyValidator, IChildValidatorAdaptor

Methods​

Add<TDerived>(IValidator<TDerived>, String[])​

Adds a validator to handle a specific subclass.

View Source​
Declaration
public PolymorphicValidator<T, TProperty> Add<TDerived>(IValidator<TDerived> derivedValidator, params string[] ruleSets)
where TDerived : TProperty
Returns​

[ServiceStack.FluentValidation.Validators.PolymorphicValidator<T, TProperty>](../ServiceStack.FluentValidation.Validators/PolymorphicValidatorT, TProperty)

Parameters​
TypeNameDescription
ServiceStack.FluentValidation.IValidator<T>derivedValidatorThe derived validator

| | System.String[] | ruleSets | Optionally specify rulesets to execute. If set, rules not in these rulesets will not be run

|

Type Parameters​
  • TDerived

Add<TDerived>(Func<T, IValidator<TDerived>>, String[])​

Adds a validator to handle a specific subclass.

View Source​
Declaration
public PolymorphicValidator<T, TProperty> Add<TDerived>(Func<T, IValidator<TDerived>> validatorFactory, params string[] ruleSets)
where TDerived : TProperty
Returns​

[ServiceStack.FluentValidation.Validators.PolymorphicValidator<T, TProperty>](../ServiceStack.FluentValidation.Validators/PolymorphicValidatorT, TProperty)

Parameters​
TypeNameDescription
System.Func<<T>,ServiceStack.FluentValidation.IValidator<<TDerived>>>validatorFactoryThe derived validator

| | System.String[] | ruleSets | Optionally specify rulesets to execute. If set, rules not in these rulesets will not be run

|

Type Parameters​
  • TDerived

Add<TDerived>(Func<T, TDerived, IValidator<TDerived>>, String[])​

Adds a validator to handle a specific subclass.

View Source​
Declaration
public PolymorphicValidator<T, TProperty> Add<TDerived>(Func<T, TDerived, IValidator<TDerived>> validatorFactory, params string[] ruleSets)
where TDerived : TProperty
Returns​

[ServiceStack.FluentValidation.Validators.PolymorphicValidator<T, TProperty>](../ServiceStack.FluentValidation.Validators/PolymorphicValidatorT, TProperty)

Parameters​
TypeNameDescription
System.Func<<T>,<TDerived>,ServiceStack.FluentValidation.IValidator<<TDerived>>>validatorFactoryThe derived validator

| | System.String[] | ruleSets | Optionally specify rulesets to execute. If set, rules not in these rulesets will not be run

|

Type Parameters​
  • TDerived

Add(Type, IValidator, String[])​

Adds a validator to handle a specific subclass. This method is not publicly exposed as it takes a non-generic IValidator instance which could result in a type-unsafe validation operation. It allows derived validaors more flexibility in handling type conversion. If you make use of this method, you should ensure that the validator can correctly handle the type being validated.

View Source​
Declaration
protected PolymorphicValidator<T, TProperty> Add(Type subclassType, IValidator validator, params string[] ruleSets)
Returns​

[ServiceStack.FluentValidation.Validators.PolymorphicValidator<T, TProperty>](../ServiceStack.FluentValidation.Validators/PolymorphicValidatorT, TProperty)

Parameters​
TypeNameDescription
System.TypesubclassType

| | ServiceStack.FluentValidation.IValidator | validator |

| | System.String[] | ruleSets | Optionally specify rulesets to execute. If set, rules not in these rulesets will not be run

|

GetValidator(PropertyValidatorContext)​

View Source​
Declaration
public override IValidator<TProperty> GetValidator(PropertyValidatorContext context)
Returns​

ServiceStack.FluentValidation.IValidator<T>

Parameters​
TypeName
ServiceStack.FluentValidation.Validators.PropertyValidatorContextcontext

CreateNewValidationContextForChildValidator(PropertyValidatorContext, IValidator<TProperty>)​

View Source​
Declaration
protected override IValidationContext CreateNewValidationContextForChildValidator(PropertyValidatorContext context, IValidator<TProperty> validator)
Returns​

ServiceStack.FluentValidation.IValidationContext

Parameters​
TypeName
ServiceStack.FluentValidation.Validators.PropertyValidatorContextcontext
ServiceStack.FluentValidation.IValidator<T>validator

Implements​